package com;
import com.DAO.StudentDao;

import java.sql.SQLException;

public class Grade {
    private int id;
    private int studentId;
    private String courseName;
    private double grade;

    // 无参构造函数
    public Grade() {
    }

    // 带参构造函数
    public Grade(int studentId, String courseName, double grade) {
        this.studentId = studentId;
        this.courseName = courseName;
        this.grade = grade;
    }

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getStudentId() {
        return studentId;
    }

    public void setStudentId(int studentId) {
        this.studentId = studentId;
    }

    public String getCourseName() {
        return courseName;
    }

    public void setCourseName(String courseName) {
        this.courseName = courseName;
    }

    public double getGrade() {
        return grade;
    }

    public void setGrade(String grade) {
        this.grade = Double.parseDouble(grade);
    }

    /*public String getStudentName() {

    StudentDao studentDao = new StudentDao();
    Student student = null;
    try {
        student = studentDao.getStudentById(studentId);
    } catch (SQLException e) {
        e.printStackTrace();
    }
    return student != null ? student.getName() : "未知";
    }*/
    private String studentName;
    public String getStudentName() {
        return studentName != null ? studentName : "未知";
    }

    // 在获取成绩时，通过 GradeDao 或其他方式设置学生姓名
    public void setStudentName(String studentName) {
        this.studentName = studentName;
    }
}



